/* $RCSFile: LicenseKeysCollection.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/ADNCRM.ServerControls/LicenseKeysCollection.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:30  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace ADNCRM.ServerControls
{
    /// <summary>
    /// Summary description for IndexesCollection
    /// </summary>
    public class LicenseKeysCollection : ConfigurationElementCollection
    {
        public LicenseKey this[int index]
        {
            get
            {
                return base.BaseGet(index) as LicenseKey;
            }
            set
            {
                if (base.BaseGet(index) != null)
                {
                    base.BaseRemoveAt(index);
                }
                this.BaseAdd(index, value);
            }
        }

       new public LicenseKey this[string Name]
        {
            get
            {
                return (LicenseKey)BaseGet(Name);
            }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new LicenseKey();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((LicenseKey)element).Product;
        }

        /**/
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.AddRemoveClearMap;
            }
        }

        protected override ConfigurationElement CreateNewElement(string productName)
        {
            return new LicenseKey(productName);
        }

        public new string AddElementName
        {
            get
            { return base.AddElementName; }

            set
            { base.AddElementName = value; }

        }

        public new string ClearElementName
        {
            get
            { return base.ClearElementName; }

            set
            { base.AddElementName = value; }

        }

        public new string RemoveElementName
        {
            get
            { return base.RemoveElementName; }
        }

        public new int Count
        {
            get { return base.Count; }
        }

 
        public int IndexOf(LicenseKey product)
        {
            return BaseIndexOf(product);
        }

        public void Add(LicenseKey product)
        {
            BaseAdd(product);
            // Add custom code here.
        }

        protected override void BaseAdd(ConfigurationElement element)
        {
            BaseAdd(element, false);
            // Add custom code here.
        }

        public void Remove(LicenseKey productLic)
        {
            if (BaseIndexOf(productLic) >= 0)
                BaseRemove(productLic.Product);
        }

        public void RemoveAt(int index)
        {
            BaseRemoveAt(index);
        }

        public void Remove(string name)
        {
            BaseRemove(name);
        }

        public void Clear()
        {
            BaseClear();
            // Add custom code here.
        }
   }
}